<?php
/**
 * Created by PhpStorm.
 * User: 盛茂国
 * Tel: 18394333958
 * Date: 2020/6/2
 * Time: 10:31
 */
namespace app\api\controller;


use app\admin\command\Api;
use think\Request;

class Banner extends Api
{
    protected $noNeedLogin=['index'];
    protected $noNeedRight=[];
    public function index(Request $request){
        if($request->isPost()){
            $banner=new \app\admin\model\Banner();
            $obj=$banner->where('switch','=',1)->select();
            $data=collection($obj)->toArray();

            foreach ($data as $key=>$value){
                $data[$key]['image']=$request->domain().$value['image'];
            }
            if(!empty($data)){
                return json(['code'=>200,'msg'=>'获取广告图成功','data'=>$data]);
            }else{
                return json(['code'=>201,'msg'=>'现在还没有广告图，请等待平台上传']);
            }
        }else{
            return json([
                'code'=>200,
                'msg'=>'非法请求'
            ]);
        }

    }
}